<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        img{
            width: 150px;
            height: 150px;
        }
    </style>
</head>
<body>
    <div id="ooo">
       <div> <img src="./img/1.jpg" alt=""></div>
       <div>  <img src="./img/2.jpg" alt="">
        <img src="./img/3.jpg" alt="">
        <img src="./img/4.jpg" alt=""></div>
    </div>
    <script>
        window.onload = function() {
          var oSmalImg = document.getElementById("ooo").getElementsByTagName("img");
            
          for (var i=1;i<oSmalImg.length;i++) {
              oSmalImg[i].index = i;
              oSmalImg[i].onmouseover = function() {
                  oSmalImg[0].src = "./img/" + this.index + ".jpg";
              };
          }
        };
    </script>
</body>
</html>